package cn.edu.sjtu.se.dslab.component.method;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.edu.sjtu.se.dslab.component.data.DomainEntity;

/**
 * 该类用于表示MethodComponent与DomainEntity之间的映射关系,DomainEntity可以是其子类，例如AvionicsEquipment
 * @author sunke
 *
 */
@Entity
@Table(name = "method_domain")
public class MethodToDomain implements Serializable {
	private static final long serialVersionUID = 1L;

	private long id;
	
	private MethodComponent component;
	
	private DomainEntity entity;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "component_id")
	public MethodComponent getComponent() {
		return component;
	}
	public void setComponent(MethodComponent component) {
		this.component = component;
	}
	
	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "entity_id")
	public DomainEntity getEntity() {
		return entity;
	}
	public void setEntity(DomainEntity entity) {
		this.entity = entity;
	}
	
}
